<!--
 * @Description: 渠道搜索页面
 * @Version: 1.0
 * @Author: Yuanjy
 * @Date: 2020-04-14 21:31:58
 * @LastEditors: Yuanjy
 * @LastEditTime: 2020-04-18 16:42:39
 -->
<template>
  <div class="head-container">
    <!-- 搜索 -->
    <el-input v-model="query.name" placeholder="一级渠道名称" class="filter-item" style="width: 200px;" @keyup.enter.native="toQuery" />
    <el-input v-model="query.code" placeholder="渠道代码" class="filter-item" style="width: 200px;" @keyup.enter.native="toQuery" />
    <el-button class="filter-item" size="mini" type="primary" icon="el-icon-search" @click="toQuery">搜索</el-button>
    <!-- 新增 -->
    <div style="display: inline-block;margin: 0px 2px;">
      <el-button
        v-if="checkPermission(['ADMIN'])"
        class="filter-item"
        size="mini"
        type="primary"
        icon="el-icon-plus"
        @click="$refs.form.dialog = true">新增一级渠道</el-button>
      <eForm ref="form" :is-add="true" />
    </div>
  </div>
</template>

<script>
import checkPermission from '@/utils/permission' // 权限判断函数
import eForm from './form'

export default {
  components: { eForm },
  props: {
    query: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      queryTypeOptions: [
        { key: 'id', display_name: 'ID' },
        { key: 'name', display_name: '配置名称' },
        { key: 'description', display_name: '配置描述' }
      ]
    }
  },
  methods: {
    checkPermission,
    toQuery() {
      this.$parent.page = 0
      this.$parent.init()
    }
  }
}
</script>
